/*
 *  YATUN  - Yet another tunneling application
 *
 *  Michal Demin - 2007
 *
 *  YATUN.h
 *  Zakladne definicie 
 *
 */

#ifndef YATUN_h
#define YATUN_h

#include <arpa/inet.h>

#define DEFAULT_PORT 		21212
#define DEFAULT_CONFIG		"yatun.conf"

#define YATUN_PACKET_LENGHT_MAX	2048
// Negotiation flags ...
#define YATUN_HELLO			0x0001
#define YATUN_TCP			0x0002
#define YATUN_UDP			0x0004
#define YATUN_ACK			0x0008
#define YATUN_USE_ENC			0x0010
#define YATUN_USE_COMP			0x0020
#define YATUN_ahdsaojdsa			0x0000

//Packet Flags definitions
#define YATUN_PACKET_DATA		0x0001
#define YATUN_PACKET_CTRL		0x0002
#define YATUN_PACKET_COMP		0x0004
#define YATUN_PACKET_ENC			0x0008
#define YATUN_PACKET_KEEPALIVE		0x0010
#define YATUN_PACKET_KEEPREPLY		0x0020
#define YATUN_PACKET_ACK			0x0040

#define YATUN_OVERHEAD	(sizeof(Packet) - YATUN_PACKET_LENGHT_MAX)

#define YATUN_PACKET_2NET(Pack) \
do { \
    (Pack)->Lenght = htons((Pack)->Lenght); \
    (Pack)->Flag = htons((Pack)->Flag); \
    (Pack)->SeqNum = htons((Pack)->SeqNum); \
} while (0);

#define YATUN_PACKET_2HOST(Pack) \
do { \
    (Pack)->Lenght = ntohs((Pack)->Lenght); \
    (Pack)->Flag = ntohs((Pack)->Flag); \
    (Pack)->SeqNum = ntohs((Pack)->SeqNum); \
} while (0);


struct Packet
{
  short Lenght;
  short Flag;
  unsigned short SeqNum;
  char Data[YATUN_PACKET_LENGHT_MAX];
};

#endif
